/**
 * Created by Administrator on 2017/8/1.
 */

angular.module('WfbPlatformApp')
  .factory('walletService', ['$http', '$q', function ($http, $q) {

    return {

      getCoinPrice: function (paramData) {
        var deferred = $q.defer();
        $http({
          method: 'POST',
          url: 'wallet/coinprice',
          data: paramData
        }).then(function success(result) {
            if (result.data.retCode == '1') {
              // 请求成功
              deferred.resolve(result.data);
            }
          },
          function error(error) {
            deferred.reject(error);//请求失败
          }
        );
        return deferred.promise;//返回承诺
      },

      getUserWallet: function (paramData)
      {
        var deferred = $q.defer();
        $http({
          method: 'POST',
          url: 'wallet/userwallet',
          data: paramData
        }).then(function success(result) {
            if (result.data.retCode == '1') {
              // 请求成功
              deferred.resolve(result.data);
            }
          },
          function error(error) {
            deferred.reject(error);//请求失败
          }
        );
        return deferred.promise;//返回承诺
      },
    };

  }]);
